home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / user.cpp < prev    next >
C/C++ Source or Header  |  1996-03-05  |  19KB  |  883 lines

  1. /******************************************************************************
  2. ******************************************************************************/
  3.  
  4. // User Interface routines...
  5.  
  6. /******************************************************************************
  7. ******************************************************************************/
  8.  
  9. #include <math.h>
  10. #include <string.h>
  11. #include <stdio.h>
  12.  
  13. #include "defines.h"
  14. #include "mouse.h"
  15. #include "externs.h"
  16.  
  17. extern char on_3d;
  18. extern void editor_main();
  19.  
  20. /******************************************************************************
  21. ******************************************************************************/
  22.  
  23. void init_keyboard()
  24. {
  25.     key2[UP_KEY]=0x1e;        // A
  26.     key2[DN_KEY]=0x2c;        // Z
  27.     key2[LF_KEY]=0x33;        // <
  28.     key2[RT_KEY]=0x34;        // >
  29.     key2[F1_KEY]=0x10;        // Q
  30.     key2[F2_KEY]=0x35;        // /
  31.  
  32.     key1[UP_KEY]=-0x48;        // Arrow Up
  33.     key1[DN_KEY]=-0x50;        // Arrow Dn
  34.     key1[LF_KEY]=-0x4b;        // Arrow Lf
  35.     key1[RT_KEY]=-0x4d;        // Arrow Rt
  36.     key1[F1_KEY]=0x52;        // 0(num)
  37.     key1[F2_KEY]=0x53;        // .(num)
  38. }
  39.  
  40. /******************************************************************************
  41. ******************************************************************************/
  42.  
  43. void delete_net_user(int u)
  44. {
  45.     users_left--;
  46.     if (u==user_taker)
  47.         user_taker=FALSE;
  48.  
  49.     short tm=0;
  50.  
  51.     int i;
  52.     char copy=FALSE;
  53.  
  54.     short type=users[u-1].type;
  55.  
  56.     if (type<0)
  57.     {
  58. // Auto Player...
  59.         if (type==-1)
  60.         {
  61. // Auto-user A.
  62.             for (i=0; i<auto_users_a; i++)
  63.             {
  64.                 if (auto_users_list_a[i]==u)
  65. // Found user...
  66.                 {
  67. /*
  68.                     if (last_user_a>=i && last_user_a)
  69.                         last_user_a--;
  70.  
  71.                     if (play_ball_a>=i && play_ball_a)
  72.                         play_ball_a--;
  73. */
  74.                     copy=TRUE;
  75.                 }
  76.  
  77.                 if (copy && i<auto_users_a)
  78.                     auto_users_list_a[i]=auto_users_list_a[i+1];
  79.             }
  80.  
  81.             auto_users_a--;
  82.         }
  83.         else
  84.         {
  85. // Auto-user B.
  86.             for (i=0; i<auto_users_b; i++)
  87.             {
  88.                 if (auto_users_list_b[i]==u)
  89. // Found user...
  90.                 {
  91. /*
  92.                     if (last_user_b>=i && last_user_b)
  93.                         last_user_b--;
  94.  
  95.                     if (play_ball_b>=i && play_ball_b)
  96.                         play_ball_b--;
  97. */
  98.                     copy=TRUE;
  99.                 }
  100.  
  101.                 if (copy && i<auto_users_b)
  102.                     auto_users_list_b[i]=auto_users_list_b[i+1];
  103.             }
  104.  
  105.             auto_users_b--;
  106.         }
  107.     }
  108.     else
  109.     {
  110. // Fixed Player...
  111.         if (fixed_net_user==u)
  112.             fixed_net_user=0;
  113.     }
  114.  
  115.     for (i=0; i<22; i++)
  116.     {
  117.         if (teams[i].control==u)
  118.             teams[i].control=FALSE;        // No user control of player!
  119.     }
  120.  
  121.     users[u-1].type=0;
  122.     users[u-1].control=NO_CTRL;
  123.  
  124.     sprintf(glob_str1,"USER %d has quit!",u);
  125.     add_message(&glob_str1[0],RED,TRUE);
  126.  
  127.     if (users_left==1)
  128.         sprintf(glob_str2,"You are now the only user in the game!");
  129.     else
  130.         sprintf(glob_str2,"There are %d users left in the game!",users_left);
  131.  
  132.     add_message(&glob_str2[0],YELLOW);
  133. }
  134.  
  135. /******************************************************************************
  136. ******************************************************************************/
  137.  
  138. // Add team user.
  139.  
  140. void add_team_user(short t,short c)
  141. {
  142.     users[num_of_users].type=t;                        // User team.
  143.     users[num_of_users].control=c;                    // Control type.
  144.     users[num_of_users++].plr=-1;                        // Current player.
  145.  
  146. /*
  147.     if (c==JOY1_CTRL)
  148.         joystick1_on=TRUE;
  149.     if (c==JOY2_CTRL)
  150.         joystick2_on=TRUE;
  151. */
  152.     if (t==-1)
  153.         auto_users_list_a[auto_users_a++]=num_of_users;
  154.     if (t==-2)
  155.         auto_users_list_b[auto_users_b++]=num_of_users;
  156.  
  157. #ifdef SUPPORT_LP
  158.     if (c==LOGPAD_CTRL)
  159.         lp_user=num_of_users;
  160. #endif
  161. }
  162.  
  163. /******************************************************************************
  164. ******************************************************************************/
  165.  
  166. // Add User as fixed player.
  167.  
  168. void add_fixed_user(short p,short c)
  169. {
  170.     users[num_of_users].type=p;                        // User fixed player.
  171.     users[num_of_users].control=c;                    // Control type.
  172.     users[num_of_users++].plr=p;                        // Current player.
  173.  
  174. /*
  175.     if (c==JOY1_CTRL)
  176.         joystick1_on=TRUE;
  177.     if (c==JOY2_CTRL)
  178.         joystick2_on=TRUE;
  179. */
  180.  
  181.     teams[p-1].control=num_of_users;                    // Tag player as user controlled!
  182.  
  183.     if (c!=NET_CTRL && network_on)
  184.         fixed_net_user=num_of_users;
  185.  
  186. #ifdef SUPPORT_LP
  187.     if (c==LOGPAD_CTRL)
  188.         lp_user=num_of_users;
  189. #endif
  190. }
  191.  
  192. /******************************************************************************
  193. ******************************************************************************/
  194.  
  195. // Initialise Fixed control players.
  196.  
  197. void clear_all_fixed()
  198. {
  199.     for (int i=0; i<players; i++)
  200.     {
  201.         teams[i].control=FALSE;
  202.     }
  203. }
  204.  
  205. /******************************************************************************
  206. ******************************************************************************/
  207.  
  208. // Initialise User Configuration Table...
  209.  
  210. void init_users()
  211. {
  212.     memset((void *)users,0,MAX_NET_USERS*(sizeof(user_config)));
  213.     num_of_users=0;
  214.     auto_users_a=0;
  215.     auto_users_b=0;
  216.     fixed_net_user=0;
  217.     clear_all_fixed();
  218.  
  219. //    add_team_user(TEAM_A,MOUSE_CTRL);
  220. //    add_team_user(TEAM_A,KEY1_CTRL);
  221. //    add_team_user(TEAM_A,KEY2_CTRL);
  222. //    add_team_user(TEAM_A,JOY1_CTRL);
  223. //    add_team_user(TEAM_A,KEY2_CTRL);
  224. //    add_fixed_user(15,JOY2_CTRL);
  225. //    add_team_user(TEAM_A,KEY2_CTRL);
  226. //    add_fixed_user(11,KEY1_CTRL);
  227. }
  228.  
  229. /******************************************************************************
  230. ******************************************************************************/
  231.  
  232. void go_button()
  233. {
  234.     switch(button_lit)
  235.     {
  236.         case 1:
  237.         {
  238.             in_game=FALSE;
  239.             break;
  240.         }
  241.         case 2:
  242.         {
  243.             grid_map();                    //Draw zonal grid on pitch.
  244.             MouseRelease();
  245.             break;
  246.         }
  247.         case 3:
  248.         {
  249.             faster();                    //Speed up.
  250.             break;
  251.         }
  252.         case 4:
  253.         {
  254.             slower();                    //Slow down.
  255.             break;
  256.         }
  257.         case 5:
  258.         {
  259.               show_nums();                //Show player nos.
  260.               MouseRelease();
  261.             break;
  262.         }
  263.         case 6:
  264.         {
  265.               set_xyspin++;                //Add clockwise swerve.
  266.               MouseRelease();
  267.             break;
  268.         }
  269.         case 7:
  270.         {
  271.               set_xyspin--;                //Add anti-clockwise swerve.
  272.               MouseRelease();
  273.             break;
  274.         }
  275.         case 8:
  276.         {
  277.               set_zspin++;                //Add Top-spin swerve.
  278.               MouseRelease();
  279.             break;
  280.         }
  281.         case 9:
  282.         {
  283.               set_zspin--;                //Add Back-spin swerve.
  284.               MouseRelease();
  285.             break;
  286.         }
  287.         case 10:
  288.         {
  289. //              on_3d=TRUE;                    //Use 3d display.
  290.             break;
  291.         }
  292.  
  293.     }
  294. }
  295.  
  296. /******************************************************************************
  297. *****************************************************************************/
  298.  
  299. void mouse_fired()
  300. {
  301.     if (!on_3d)
  302.     {
  303.         if (button_lit)
  304.             go_button();
  305.     }
  306. }
  307.  
  308. /******************************************************************************
  309. *****************************************************************************/
  310.  
  311. void process_butts()
  312. {
  313.     int x,y,w;
  314.     for (int i=0; i<max_butts; i++)
  315.     {
  316.         x=us_buttons[i].x;
  317.         y=us_buttons[i].y;
  318.         w=us_buttons[i].w;
  319.         if ((Mouse.x/2>=x-4) && (Mouse.x/2<=x+(w*8)+4)
  320.             && (Mouse.y>=y-4) && (Mouse.y<=y+12))
  321.         {
  322.             if (!us_buttons[i].l)
  323.             {
  324.                 light_button(i);            //Mouse will highlight button.
  325.                 us_buttons[i].l=1;
  326.             }
  327.         }
  328.         else
  329.         {
  330.             if (us_buttons[i].l)
  331.             {
  332.                 unlight_button(i);
  333.                 us_buttons[i].l=0;
  334.             }
  335.         }
  336.     }
  337. }        
  338.  
  339. /******************************************************************************
  340. *****************************************************************************/
  341.  
  342.  
  343. // Low level input code has moved to network.c...
  344.  
  345.  
  346. /******************************************************************************
  347. *****************************************************************************/
  348.  
  349. // Converts integer input from interrupts into expected data in users_dir array
  350.  
  351. void convert_inputs()
  352. {
  353.     short x,y;
  354.     for (int i=0; i<num_of_users; i++)
  355.     {
  356.         x=users_dir_i[readptr][i].x_f1;
  357.         y=users_dir_i[readptr][i].y_f2;
  358.  
  359.         if (x==12345&&y==12345)    // Magic quit data from master in network game
  360.             delete_net_user(i+1);
  361.         else
  362.         {
  363.             users_dir[i].f=(x&1)|((y&1)<<1);
  364.  
  365. #ifdef EURO96
  366.             users_dir[i].f+=((x&6)<<1);
  367.             users_dir[i].f+=((y&6)<<3);
  368.  
  369.             x&=0xfff8;
  370.             y&=0xfff8;
  371. #else
  372.  
  373. #ifdef SUPPORT_LP
  374.             if (users[i].control==LOGPAD_CTRL)
  375.             {
  376.                 users_dir[i].f+=((x&6)<<1);
  377.                 users_dir[i].f+=((y&6)<<3);
  378.             }
  379.  
  380.             x&=0xfff8;
  381.             y&=0xfff8;
  382. #else
  383.             x&=0xfffe;
  384.             y&=0xfffe;
  385. #endif
  386.  
  387. #endif
  388.             users_dir[i].m=(x || y);
  389.             users_dir[i].x=x/32768.;
  390.             users_dir[i].y=y/32768.;
  391.  
  392.         }
  393.     }
  394. }
  395.  
  396.  
  397. /******************************************************************************
  398. *****************************************************************************/
  399.  
  400. // Reset Auto-selected User...
  401.  
  402. void clear_auto(short u)
  403. {
  404.     users[u-1].plr=0;
  405.  
  406.     for (int i=1; i<=players; i++)
  407.     {
  408.         if (teams[i-1].control==u)
  409.         {
  410.             teams[i-1].control=FALSE;
  411.             teams[i-1].tm_htype=FALSE;
  412.         }
  413.     }
  414. }
  415.  
  416. /******************************************************************************
  417. *****************************************************************************/
  418.  
  419. // Reset All Auto-selected Users...
  420.  
  421. void clear_all_autos()
  422. {
  423.     for (short i=0; i<auto_users_a; i++)
  424.     {
  425.         clear_auto(auto_users_list_a[i]);
  426.     }
  427.     for (i=0; i<auto_users_b; i++)
  428.     {
  429.         clear_auto(auto_users_list_b[i]);
  430.     }
  431. }
  432.         
  433. /******************************************************************************
  434. *****************************************************************************/
  435.  
  436. void reset_f_held()
  437. {
  438.     f1_down=FALSE;
  439.     f2_down=FALSE;
  440. }
  441.  
  442. /******************************************************************************
  443. *****************************************************************************/
  444.  
  445. short user_keeper_a()
  446. {
  447.     short u=teams[KP_A-1].control;
  448.     if (!u)
  449.         if (auto_users_a)
  450.         {
  451.             if (++play_ball_a>=auto_users_a)
  452.                 play_ball_a=0;
  453.             u=auto_users_list_a[play_ball_a];
  454.             clear_auto(u);
  455.         }
  456.         else
  457.             u=0;
  458.  
  459.     return(u);
  460. }
  461.  
  462. /******************************************************************************
  463. *****************************************************************************/
  464.  
  465. short user_keeper_b()
  466. {
  467.     short u=teams[KP_B-1].control;
  468.     if (!u)
  469.         if (auto_users_b)
  470.         {
  471.             if (++play_ball_b>=auto_users_b)
  472.                 play_ball_b=0;
  473.             u=auto_users_list_b[play_ball_b];
  474.             clear_auto(u);
  475.         }
  476.         else
  477.             u=0;
  478.  
  479.     return(u);
  480. }
  481.  
  482. /******************************************************************************
  483. *****************************************************************************/
  484.  
  485. short user_taker_a(short p)
  486. {
  487.     reset_f_held();
  488.     short u=teams[p-1].control;
  489.     if (!u)
  490.     {
  491.         if (auto_users_a)
  492.         {
  493.             if (++play_ball_a>=auto_users_a)
  494.                 play_ball_a=0;
  495.             u=auto_users_list_a[play_ball_a];
  496.             clear_auto(u);
  497.         }
  498.         else
  499.             u=0;
  500.     }
  501.     return(u);
  502. }
  503.  
  504. /******************************************************************************
  505. *****************************************************************************/
  506.  
  507. short user_taker_b(short p)
  508. {
  509.     reset_f_held();
  510.     short u=teams[p-1].control;
  511.     if (!u)
  512.     {
  513.         if (auto_users_b)
  514.         {
  515.             if (++play_ball_b>=auto_users_b)
  516.                 play_ball_b=0;
  517.             u=auto_users_list_b[play_ball_b];
  518.             clear_auto(u);
  519.         }
  520.         else
  521.             u=0;
  522.     }
  523.     return(u);
  524. }
  525.  
  526. /******************************************************************************
  527. *****************************************************************************/
  528.  
  529. void auto_select_a(short u)
  530. {
  531. // Team A...
  532.     closest=FALSE;
  533.  
  534.     last_plr_a=users[u-1].plr;
  535.  
  536.     if (!(ball_poss && u==teams[ball_poss-1].control))
  537. // This guy doesn't have ball!
  538.     {
  539.         if (ball_poss!=KP_A && ball_poss<=players/2 && ball_poss
  540.              && !teams[ball_poss-1].control)
  541.         {
  542. // His team-mate has ball who isn't a user... (make him this user!)
  543.             clear_auto(u);
  544.             users[u-1].chng=TRUE;                // changed control.
  545.  
  546.             reset_ideas(&teams[ball_poss-1]);
  547.             teams[ball_poss-1].control=u;
  548.             users[u-1].plr=ball_poss;
  549.         }
  550.         else
  551. // Get closest...
  552.         {
  553.             short main_guy;
  554.             if (user_taker2==u)
  555.                 main_guy=KP_A;
  556.             else
  557.                 if (receiver_a)
  558.                     main_guy=receiver_a;
  559.                 else
  560.                     if (interceptor_a)
  561.                         main_guy=interceptor_a;
  562.                     else
  563.                         if (near_path_a)
  564.                             main_guy=near_path_a;
  565.                         else
  566.                             main_guy=0;
  567.  
  568.             float d;
  569.             int guy=0;
  570.             float lowest=2000;
  571.  
  572.             for (int i=1; i<12; i++)
  573.             {
  574.                 if ((i!=KP_A || match_mode==GOAL_KICK_BL || match_mode==GOAL_KICK_TL || user_taker2)
  575.                      && teams[i-1].guy_on>0 && (!teams[i-1].control || teams[i-1].control==u))
  576.                 {
  577.                     if (teams[i-1].tm_act!=FALL_ACT)
  578.                     {
  579.                          if (i==main_guy)
  580.                              d=1;
  581.                          else
  582.                              d=teams[i-1].tm_dist;
  583.  
  584.                         if (d<lowest)
  585.                         {
  586.                             guy=i;
  587.                             lowest=d;
  588.                         }
  589.                     }
  590.                 }
  591.             }
  592.  
  593.             if (guy!=last_plr_a && guy && 
  594.                 (last_plr_a<=0 || (last_plr_a>0 && !sel_circle[last_plr_a-1]) || receiver_a))
  595.             {
  596.                 clear_auto(u);
  597.                 teams[guy-1].control=u;
  598.                 users[u-1].chng=TRUE;                // changed control
  599.                 users[u-1].plr=guy;
  600.             }
  601.         }
  602.     }
  603. }
  604.  
  605.  
  606. /******************************************************************************
  607. *****************************************************************************/
  608.  
  609. void auto_select_b(short u)
  610. {
  611. // Team B...
  612.     closest=FALSE;
  613.  
  614.     last_plr_b=users[u-1].plr;
  615.         
  616.     if (!(ball_poss && u==teams[ball_poss-1].control))
  617. // This guy doesn't have ball!
  618.     {
  619.         if (ball_poss!=KP_B && ball_poss>players/2
  620.              && !teams[ball_poss-1].control)
  621.         {
  622. // His team-mate has ball who isn't a user... (make him this user!)
  623.             clear_auto(u);
  624.             users[u-1].chng=TRUE;                // changed control.
  625.  
  626.             reset_ideas(&teams[ball_poss-1]);
  627.             teams[ball_poss-1].control=u;
  628.             users[u-1].plr=ball_poss;
  629.         }
  630.         else
  631. // Get closest...
  632.         {
  633.             short main_guy;
  634.             if (user_taker2==u)
  635.                 main_guy=KP_B;
  636.             else
  637.                 if (receiver_b)
  638.                     main_guy=receiver_b;
  639.                 else
  640.                     if (interceptor_b)
  641.                         main_guy=interceptor_b;
  642.                     else
  643.                         if (near_path_b)
  644.                             main_guy=near_path_b;
  645.                         else
  646.                             main_guy=0;
  647.  
  648.             float d;
  649.             int guy=0;
  650.             float lowest=2000;
  651.  
  652.             for (int i=12; i<=players; i++)
  653.             {
  654.                 if ((i!=KP_B || match_mode==GOAL_KICK_BR || match_mode==GOAL_KICK_TR || user_taker2)
  655.                      && teams[i-1].guy_on>0 && (!teams[i-1].control || teams[i-1].control==u))
  656.                 {
  657.                     if (teams[i-1].tm_act!=FALL_ACT)
  658.                     {
  659.                         if (i==main_guy)
  660.                             d=1;
  661.                         else
  662.                             d=teams[i-1].tm_dist;
  663.  
  664.                         if (d<lowest)
  665.                         {
  666.                             guy=i;
  667.                             lowest=d;
  668.                         }
  669.                     }
  670.                 }
  671.             }
  672.  
  673.             if (guy!=last_plr_b && guy &&
  674.                 (last_plr_b<=0 || (last_plr_b>0 && !sel_circle[last_plr_b-1]) || receiver_b))
  675.             {
  676.                 clear_auto(u);
  677.                 teams[guy-1].control=u;
  678.                 users[u-1].chng=TRUE;                // changed control
  679.                 users[u-1].plr=guy;
  680.             }
  681.         }
  682.     }
  683. }
  684.  
  685. /******************************************************************************
  686. *****************************************************************************/
  687.  
  688. void reselect_a()
  689. {
  690. // Team A!
  691.     short user,maxu,au,max_au;
  692.     signed char p;
  693.     float max=-1;
  694.     float d;
  695.  
  696.     if (auto_users_a)
  697.     {
  698.         if (last_user_a==auto_users_a)
  699.             last_user_a=0;
  700.  
  701.         maxu=auto_users_list_a[last_user_a];
  702.  
  703.         if (++last_user_a==auto_users_a)
  704.             last_user_a=0;
  705.  
  706.         au=last_user_a;
  707.         max_au=au;
  708.  
  709.         for (short i=1; i<auto_users_a; i++)
  710.         {
  711.             if (au==auto_users_a)
  712.                 au=0;
  713.  
  714.             user=auto_users_list_a[au];
  715.             p=users[user-1].plr;
  716.             if (p<=0)
  717.                 d=1500;
  718.             else
  719.                 d=(teams[p-1].tm_dist);
  720.  
  721.             if (d>max)
  722.             {
  723.                 max=d;
  724.                 maxu=user;
  725.                 max_au=au;
  726.             }
  727.             au++;
  728.         }
  729.         auto_select_a(maxu);            // Team Control.
  730.         if (!ball_poss)
  731.             last_user_a=max_au;
  732.     }
  733. }
  734.  
  735. /******************************************************************************
  736. *****************************************************************************/
  737.  
  738. void reselect_b()
  739. {
  740. // Team B!
  741.     short user,maxu,au,max_au;
  742.     signed char p;
  743.     float max=-1;
  744.     float d;
  745.  
  746.     if (auto_users_b)
  747.     {
  748.         if (last_user_b==auto_users_b)
  749.             last_user_b=0;
  750.  
  751.         maxu=auto_users_list_b[last_user_b];
  752.  
  753.         if (++last_user_b==auto_users_b)
  754.             last_user_b=0;
  755.  
  756.         au=last_user_b;
  757.         max_au=au;
  758.  
  759.         for (short i=1; i<auto_users_b; i++)
  760.         {
  761.             if (au==auto_users_b)
  762.                 au=0;
  763.  
  764.             user=auto_users_list_b[au];
  765.             p=users[user-1].plr;
  766.             if (p<=0)
  767.                 d=1500;
  768.             else
  769.                 d=(teams[p-1].tm_dist);
  770.  
  771.             if (d>max)
  772.             {
  773.                 max=d;
  774.                 maxu=user;
  775.                 max_au=au;
  776.             }
  777.             au++;
  778.         }
  779.         auto_select_b(maxu);            // Team Control.
  780.         if (!ball_poss)
  781.             last_user_b=max_au;
  782.     }
  783. }
  784.  
  785. /******************************************************************************
  786. *****************************************************************************/
  787.  
  788. void reselect()
  789. {
  790.     predict_ball();
  791.     get_nearest();
  792.     new_select=FALSE;        // Can be same player...
  793.     closest=FALSE;
  794.     reselect_a();
  795.     reselect_b();
  796. }
  797.  
  798. /******************************************************************************
  799. *****************************************************************************/
  800.  
  801. void reselect_all_users()
  802. {
  803.     for (short i=0; i<num_of_users; i++)
  804.     {
  805.         reselect();
  806.     }
  807. }
  808.  
  809. /******************************************************************************
  810. *****************************************************************************/
  811.  
  812. #ifdef FORCE_SELECT
  813. void force_users()
  814. {
  815.     if (!match_mode && num_of_users)
  816.     {
  817.         short f_user;
  818.         for (f_user=1; f_user<=MAX_USERS; f_user++)
  819.         {
  820.             if (!(forced&1))
  821.                 forced>>=1;
  822.             else
  823.                 break;
  824.         }
  825.  
  826.         short p=users[f_user-1].plr;
  827.         short tm=(p<12 ? 12:23);
  828.         for (short i=1; i<=10; i++)
  829.         {
  830.             if (++p==tm)
  831.                 p-=10;                // Can't be keeper!
  832.  
  833.             if (sel_circle[p-1] && !teams[p-1].control)
  834.                 break;
  835.         }
  836.         if (i!=11)
  837.         {
  838. // Successfull forced selection...
  839.             if (p<12)
  840.                 last_plr_a=users[f_user-1].plr;
  841.             else
  842.                 last_plr_b=users[f_user-1].plr;
  843.  
  844.             clear_auto(f_user);
  845.             teams[p-1].control=f_user;
  846.             users[f_user-1].chng=TRUE;                // changed control
  847.             users[f_user-1].plr=p;
  848.         }
  849.     }
  850. }
  851. #endif
  852.  
  853. /******************************************************************************
  854. *****************************************************************************/
  855.  
  856. void new_users()
  857. {
  858. #ifdef NO_AUTO_SEL
  859.     if (!key_togs[0x43])
  860. #endif
  861.  
  862.     if (ball_poss && num_of_users && !match_mode)
  863.     {
  864. // Normal play with users and some-one on ball!
  865.  
  866.         if (ball_travel++>select_cnt)
  867.         {
  868.             ball_travel=0;
  869.             new_select=FALSE;        // Can be same player...
  870.              closest=TRUE;
  871.  
  872.               reselect_a();
  873.               reselect_b();
  874.         }
  875.     }
  876.  
  877. #ifdef FORCE_SELECT
  878.     if (forced)
  879.         force_users();
  880. #endif
  881. }
  882.  
  883.